package com.yingluo.abacus.boot.core.data.hibernate.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.DetachedCriteria;


public interface ICCDao<T extends Serializable, PK extends Serializable> {
	public static final String SESSIONFACTORY_DEFAULT="sessionFactory";
	
	public PK save(T entity);
	public void merge(T entity) ;
	public void update(T entity) ;
	public void saveOrUpdate(T entity) ;
	public void delete(PK id) ;
	public void deleteObject(T entity) ;
	public boolean exists(PK id) ;
	public T load(PK id);
	public T get(PK id);

	public PK saveLogic(T entity)throws Exception;
	public PK saveLogic(T entity, String loginid) throws Exception;
	public void mergeLogic(T entity) throws Exception;
	public void mergeLogic(T entity, String loginid) throws Exception;
	public void saveOrUpdateLogic(T entity)throws Exception;
	public void saveOrUpdateLogic(T entity, String loginid)throws Exception;
	public void deleteLogic(PK id)throws Exception;
	public void deleteLogic(PK id, String loginid)  throws Exception;
	public void deleteObjectLogic(T entity)throws Exception;
	public void deleteObjectLogic(T entity, String loginid)throws Exception;
	public boolean existsLogic(T entity)throws Exception;
	public T loadLogic(PK id)throws Exception;
	public T getLogic(PK id)throws Exception;
	
	public int countAll() ;
	public int countAll(Criteria criteria) ;
	public int countAllLogic(Criteria criteria) ;
	
	
	public void deleteAll(Collection<?> entities)throws Exception;
	public void deleteAllLogic(Collection<?> entities)throws Exception;
	
	public List<T> list() ;
	public List<T> list(Criteria criteria);
	public List<T> list(DetachedCriteria criteria) ;
	public List<T> list(String orderBy, boolean isAsc) ;
	public List<T> list(String propertyName, Object value) ;
	public List<T> list(Criterion criterion) ;
	public List<T> list(Criterion... criterions) ;
	public List<T> listLogic(Criteria criteria); 
	public List<T> listLogic(Criterion... criterions) ;
	
	public T uniqueResult(String propertyName, Object value);
	public T uniqueResult(Criterion... criterions);
	public T uniqueResult(Criteria criteria) ;
	public T uniqueResultLogic(Criterion... criterions);
	
	public Criteria distinct(Criteria criteria) ;
	public void flush();
	public void clear();
	public void clear(T ob);
	public Criteria createCriteria() ;
	public Criteria createCriteria(Criterion... criterions) ;
	
	public List<T> pagedQuery(Criteria criteria, Pagination<T> pagination, Criteria addorder);
	public List<T> pagedQueryLogic(Criteria criteria, Pagination<T> pagination, Criteria addorder);
	public List<T> pagedQuery(Criteria criteria, Pagination<T> pagination);
	public List<T> pagedQueryLogic(Criteria criteria, Pagination<T> pagination);
	
	
	public List<T> findByHql(final String arg0) throws Exception;
	public List<T> findByHql(final String arg0, final Object obj)throws Exception;
	public List<T> findByHql(final String arg0, final Object[] obj)throws Exception;
	public List<T> findByHql(final String arg0, final Map<String, Object> obj)throws Exception;
	public List<T> findByHql(Class<?> type, final String arg0, final Map<String, Object> obj)throws Exception;
	public List<T> findByHql(final String arg0, Pagination<T> pagination) throws Exception;
	public List<T> findByHql(final String arg0, final Object obj, Pagination<T> pagination) throws Exception;
	public List<T> findByHql(final String arg0, final Map<String, Object> obj, Pagination<T> pagination) throws Exception;
	public List<T> findByHql(Class<?> type, final String arg0, final Map<String, Object> obj, Pagination<T> pagination) throws Exception;
	
	public List<?> findByHqlLogic(final String arg0) throws Exception;
	public List<?> findByHqlLogic(final String arg0, final Map<String, Object> obj)throws Exception;
	public List<?> findByHqlLogic(Class<?> type, final String arg0, final Map<String, Object> obj)throws Exception;
	public List<?> findByHqlLogic(final String arg0, Pagination<T> pagination) throws Exception;
	public List<?> findByHqlLogic(final String arg0, final Map<String, Object> obj, Pagination<T> pagination) throws Exception;
	public List<?> findByHqlLogic(Class<?> type, final String arg0, final Map<String, Object> obj, Pagination<T> pagination) throws Exception;

	
	
	public List<?> findBySql(final String arg0) throws Exception;
	public List<?> findBySql(final String arg0, final Object obj)throws Exception;
	public List<?> findBySql(final String arg0, final Object[] obj)throws Exception;
	public List<?> findBySql(final String arg0, final Map<String, Object> obj)throws Exception;
	public List<?> findBySql(Class<?> type, final String arg0, final Map<String, Object> obj)throws Exception;
	public List<?> findBySql(final String arg0, Pagination<T> pagination) throws Exception;
	public List<?> findBySql(final String arg0, final Object obj, Pagination<T> pagination) throws Exception;
	public List<?> findBySql(final String arg0, final Map<String, Object> obj, Pagination<T> pagination) throws Exception;
	public List<?> findBySql(Class<?> type, final String arg0, final Map<String, Object> obj, Pagination<T> pagination) throws Exception;
	public List<?> findBySql(Class<?> type, final String arg0, final Object[] obj, Pagination<T> pagination) throws Exception;

	public List<?> findBySqlLogic(final String arg0) throws Exception;
	public List<?> findBySqlLogic(final String arg0, final Map<String, Object> obj)throws Exception;
	public List<?> findBySqlLogic(Class<?> type, final String arg0, final Map<String, Object> obj)throws Exception;
	public List<?> findBySqlLogic(final String arg0, Pagination<T> pagination) throws Exception;
	public List<?> findBySqlLogic(final String arg0, final Map<String, Object> obj, Pagination<T> pagination) throws Exception;
	public List<?> findBySqlLogic(Class<?> type, final String arg0, final Map<String, Object> obj, Pagination<T> pagination) throws Exception;

	
	
	public int excuteByHql(final String arg0) throws Exception;
	public int excuteByHql(final String arg0, final Object obj)throws Exception;
	public int excuteByHql(final String arg0, final Object[] obj)throws Exception;
	public int excuteByHql(final String arg0, final Map<String, Object> obj)throws Exception;
	
	public int excuteBySql(final String arg0) throws Exception;
	public int excuteBySql(final String arg0, final Object obj)throws Exception;
	public int excuteBySql(final String arg0, final Object[] obj)throws Exception;
	public int excuteBySql(final String arg0, final Map<String, Object> obj)throws Exception;

	public int callProcedure(final String sql) throws Exception;
	public int callProcedure(final String sql, final Object[] obj)throws Exception;
	public int callProcedure(final String sql, final Map<String, Object> obj)throws Exception;
	
	public Object copyBo(final Object orig) throws Exception;
	public Object copyPropertiy(final Object orig)throws Exception;

	
	public List<?> findByNamedQuery(final String queryName) throws Exception;
	public List<?> findByNamedQuery(Class<?> type, final String queryName) throws Exception;
	public List<?> findByNamedQuery(final String queryName, final Map<String, ?> params) throws Exception;
	public List<?> findByNamedQuery(Class<?> type, final String queryName, final Map<String, ?> params) throws Exception;
	public List<?> findByNamedQuery(final String queryName, Pagination<T> pagination) throws Exception;
	public List<?> findByNamedQuery(final String queryName, final Map<String, ?> params, Pagination<T> pagination) throws Exception;
	public List<?> findByNamedQuery(Class<?> type, final String queryName, final Map<String, ?> params, Pagination<T> pagination) throws Exception;
}
